{extend name="platform/base" /} {block name="main"}
<div class="row padder-v">
	<div class="col-sm-9"></div>
	<div class="col-sm-2">
		<select id="status" class="input-sm form-control">
			<option value="">请选择审核状态</option>
			<option value="0">审核中</option>
			<option value="1">已同意</option>
			<option value="-1">已拒绝</option>
			<option value="2">已转账</option>
		</select>
	</div>
	<div class="col-sm-1">
		<button class="btn btn-sm btn-default" type="button"
			onclick="LoadingInfo(1)">搜索</button>
	</div>
</div>
<section class="panel panel-default">
	<div class="table-responsive">
		<table class="table table-striped b-light text-sm">
			<colgroup>
				<col width="3%">
				<col width="10%">
				<col width="10%">
				<col width="10%">
				<col width="10%">
				<col width="10%">
				<col width="10%">
				<col width="7%">
				<col width="3%">
				<col width="8%">
				<col width="12%">
				<col width="10%">
				
			</colgroup>
			<thead>
				<tr>
					<th width="20"><input type="checkbox"></th>
					<th class="left">店铺名称</th>
					<th class="left">提现流水号</th>
					<th class="left">提现银行名称</th>
					<th class="left">提现银行账号</th>
					<th class="left">提现账户姓名</th>
					<th class="center">手机</th>
					<th class="right">提现金额</th>
					<th></th>
					<th class="center">当前状态</th>
					<th class="center">提现时间</th>
					<th class="center">操作</th>
				</tr>
			</thead>
			<tbody id="list">
				<tr></tr>
			</tbody>
		</table>
	</div>
	{include file="platform/page" /}
</section>

{/block} {block name="script"}
<script type="text/javascript">
$(function(){
	LoadingInfo(1);
});
//店铺提现列表
	function LoadingInfo(pageIndex) {
		var search_text = $("#search_text").val();
		var status = $("#status").val();
		//alert(status);
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/shop/shopaccountwithdrawlist')}",
			async : true,
			data : {
				"pageIndex" : pageIndex, "search_text" : search_text, "status" : status
			},
			success : function(data) {
				//alert(JSON.stringify(data));
				var html = '';
				$("#total_count_num").text(data["total_count"]);
				$("#page_count_num").text(data["page_count"]);
				$("#page_count").val(data["page_count"]);
				$("#pageNumber a").remove();
				if (data["data"].length > 0) {
					for (var i = 0; i < data["data"].length; i++) {
						if(data["data"][i]["status"] == 0){
							data["data"][i]["status_name"] = '审核中';
						}else if(data["data"][i]["status"] == 1){
							data["data"][i]["status_name"] = '已同意';
						}else if(data["data"][i]["status"] == -1){
							data["data"][i]["status_name"] = '已拒绝';
						}else if(data["data"][i]["status"] == 2){
							data["data"][i]["status_name"] = '已转账';
						}
						html += '<tr>';
						html += '<td><input type="checkbox" name="sub" value="'+ data['data'][i]['id']+'"></td>';
						html += '<td class="left">' + data["data"][i]["shop_name"] + '</td>';
						html += '<td class="left">' + data["data"][i]["withdraw_no"] + '</td>';
						html += '<td class="left">' + data["data"][i]["bank_name"] + '</td>';
						html += '<td class="left">' + data["data"][i]["account_number"] + '</td>';
						html += '<td class="left">' + data["data"][i]["realname"] + '</td>';
						html += '<td class="center">' + data["data"][i]["mobile"] + '</td>';
						html += '<td class="right">' + data["data"][i]["cash"] + '</td>';
						html += '<td class="right"></td>';
						html += '<td class="center">' + data["data"][i]["status_name"] + '</td>';
						html += '<td class="center">' + timeStampTurnTime(data["data"][i]["ask_for_date"]) + '</td>';
						html +="<td>";
						if(data["data"][i]["status"] == 0 ){
							html += '<a href="javascript:void(0);" onclick="audit_box(' +data["data"][i]["id"]+',' +data["data"][i]["shop_id"]+',1)">同意</a>&nbsp;<a href="javascript:void(0);" onclick="audit_box(' +data["data"][i]["id"]+',' +data["data"][i]["shop_id"]+',-1)">拒绝</a>';
						}else if(data["data"][i]["status"] == 1){
							html += '<a href="javascript:void(0);" onclick="withdrawTransferAccounts(' +data["data"][i]["id"]+')">立即转账</a>';
						}
						html +="</td>";
						html += '</tr>';
					}
				} else {
					html += '<tr><td colspan="11" style="text-align:center;">暂无符合条件的数据记录</td></tr>';
				}
				$("#list").html(html);
					var totalpage = $("#page_count").val();
			if (totalpage == 1) {
				changeClass("all");
			}
			var $html = pagenumShow(jumpNumber,totalpage,{$pageshow})
			$("#pageNumber").append($html);
			}
		});
	}	
	$("#search_text").keypress(function(e){
		if(e.keyCode == 13){
			LoadingInfo(1);
		}
	});
	function audit_box(id, shop_id, is_audit){
		if(is_audit == 1){
			$( "#dialog" ).dialog({
	            buttons: {
	            	"同意": function() {
	                    $(this).dialog('close');
	                    Andit(id,shop_id,is_audit)
	                },
	                "取消,#e57373": function() {
	                    $(this).dialog('close');                   
	                }
	            },
	            contentText:"你确定同意提现审核",
	            title:"审核提醒"
	        });
		}else{
			$( "#dialog" ).dialog({
	            buttons: {
	            	"拒绝": function() {
	                    $(this).dialog('close');
	                    Andit(id,shop_id,is_audit)
	                },
	                "取消,#e57373": function() {
	                    $(this).dialog('close');                   
	                }
	            },
	            contentText:"你确定拒绝提现审核",
	            title:"审核提醒"
	        });
		}
		
	}
	function Andit(id,shop_id,status){

                    $.ajax({
            			type : "post",
            			url : "{:__URL('PLATFORM_MAIN/shop/shopaccountwithdrawaudit')}",
            			async : true,
            			data : {
            				"id" : id,
            				"shop_id" : shop_id,
            				"status" : status
            			},
            			success : function(data) {
            				//alert(JSON.stringify(data));
            				if(data["code"] > 0 ){
            					showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/shop/shopaccountwithdrawlist')}");
            				}else{
            					showMessage('error', data["message"]);
            				}
            			}
            		})               
	}
	/**
	*转帐操作
	*/
	function withdrawTransferAccounts(id){
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/shop/withdrawTransferAccounts')}",
			async : true,
			data : {
				"id" : id
			},
			success : function(data) {
				//alert(JSON.stringify(data));
				if(data["code"] > 0 ){
					showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/shop/shopaccountwithdrawlist')}");
				}else{
					showMessage('error', data["message"]);
				}
			}
		})  
	}
</script>
{/block}
